$(document).ready(function(){
	
	$('#paymethod a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					$(this).css('color', '#3366CC');
					$(this).removeAttr('href');
					$(this).bind("click", function(){
						$('#shopPaymethodForm input[name=paymethod[]]').val( $(this).attr('value') );
						$('#shopPaymethodForm').submit();
					});
				}
			}
	);
	
	$('#feature a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					$(this).css('color', '#3366CC');
					$(this).removeAttr('href');
					$(this).bind("click", function(){
						$('#shopFeatureForm input[name=feature[]]').val( $(this).attr('value') );
						$('#shopFeatureForm').submit();
					});
				}
			}
	);
	
	$('#popularSearch a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					$(this).css('color', '#3366CC');
					$(this).removeAttr('href');
					$(this).bind("click", function(){
						$('#shopTagForm input[name=q]').val( $(this).attr('value') );
						$('#shopTagForm').submit();
					});
				}
			}
	);
	
	$('.category_tags a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					$(this).css('color', '#3366CC');
					$(this).removeAttr('href');
					$(this).bind("click", function(){
						$('#shopTagForm input[name=q]').val( $(this).attr('value') );
						$('#shopTagForm').submit();
					});
				}
			}
	);
	
	
	$('#location a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					$(this).css('color', '#3366CC');
					$(this).removeAttr('href');
					$(this).bind("click", function(){
						$('#shopLocationForm input[name=location]').val( $(this).attr('value') );
						$('#shopLocationForm').submit();
					});
				}
			}
	);
	
	$('#category_products > li > a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					
					//$(this).removeAttr('href');
					$(this).bind("mouseover", function(){
						ov($(this));
					});
				}
			}
	);
	
	$('.menu_1 a').each(
			function()
			{
				if( $(this).attr('href') )
				{
					$(this).css('cursor', 'pointer');
					//$(this).css('color', '#3366CC');  
					//$(this).removeAttr('href');
					$(this).bind("click", function(){
						//$('#productFilterForm input[name=category]').val( $(this).attr('value') );
						//$('#productFilterForm').submit();
						
						$('#shopCategoryForm input[name=category]').val( $(this).attr('value') );
						$('#shopCategoryForm').submit();
					});
				}
			}
	);
	
	$('#category_products > li > a').bind("mouseout", function(){
		inFirstLevel = false;
		setTimeout(function(){
			if( !inBlock && !inFirstLevel )
				$(".menu_1").css( 'display', 'none' );
		}, 200);
		
	});
	
	$('.menu_1 a').bind("mouseout", function(){
		delayDetect();
	});
	
	$('.menu_1').bind("mouseout", function(){
		delayDetect();
	});
	
	$('.menu_1').bind("mouseover", function(){
		inBlock = true;
		inFirstLevel = false;
	});
		
	$('.menu_1 a').bind("mouseover", function(){
		inBlock = true;
		inFirstLevel = false;
	});
	
	$('#slides_show').cycle({ 
	    fx:         'fade', 
	    timeout:     3000, 
	    pager:      '#slides_nav', 
	    fastOnEvent: true,
	    slideExpr: 'img'
	});
	
	
		$.messager.show('新手上路', '1、搜索店铺。<br> 2、发表点评。<a href="http://www.huakaili.com/help/?subpage=201">进一步了解</a>', 0);	
});

function delayDetect()
{
	inBlock = false;
	setTimeout(function(){
		if( !inBlock && !inFirstLevel )
			$(".menu_1").css( 'display', 'none' );
	}, 100);
}

var inBlock = false;
var inFirstLevel = false;
function ov( objMenu)
{
	inFirstLevel = true;
	$(".menu_1").css( 'display', 'none' );
	var menuId = objMenu.attr('value');
	var subMenu = $(".menu_1[value=" + menuId + "]");
	var pLeft = objMenu.offset().left + objMenu.width() + 37;
	var pTop = objMenu.offset().top-2;
	subMenu.css( 'left', pLeft );
	subMenu.css( 'top', pTop );
	subMenu.css( 'z-index', '100' );
	subMenu.css( 'display', 'block' );
	
}

$(window).load(function() {

	$(".Hot_Reviews_Index img, .hot_store_index img, .right_rank img").each(function() {
	
	 if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) || this.readyState == 'uninitialized' ){
					
			this.src = edp_static_domain_url+'image/defaultpicture80.gif';
	}});
	
	$(".hot_prod_index img").each(function() {

		if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) || this.readyState == 'uninitialized' ){
	
			this.src = edp_static_domain_url+'image/nopicture80.gif';
	}});

});


